package com.synjones.beijing.controls
{
    import mx.rpc.events.FaultEvent;
    import mx.controls.ComboBox;
    import mx.collections.*;
    import mx.rpc.AbstractService;
    import mx.rpc.AsyncToken;
    import mx.rpc.events.ResultEvent;
    import mx.utils.ArrayUtil;
	import com.synjones.beijing.*;
	import mx.controls.Alert;
	import flash.events.Event;
	
    public class ComboBoxProc extends ComboBox
    {
        public function ComboBoxProc()
        {
            super();
        }
        
        [Bindable]	       
        private var _dataProvider:ArrayCollection = new ArrayCollection();
        private var service:AbstractService; 
           
           	
        //获取手续列表=========================================================================================
        public function Init() : void{
        	service = ServiceLocator.getRestaurantService();
        	var token: AsyncToken = AsyncToken(service.IO_PROCS_GetProcs(""));
            token.addResponder(new TokenResponder(getResult, "获取角色信息失败"));
        }
        
        private function getResult(event:ResultEvent):void{  
            _dataProvider = event.result as ArrayCollection;
            dataProvider = _dataProvider;
            labelField = "PROCNAME";
        }        
       
        public function set selectedProc(code:String):void{
            var i:int = 0;
            this.selectedIndex = 0;
            for(i=0;i<_dataProvider.length;i++){
                if(_dataProvider[i].PROCID == code){
                    this.selectedIndex = i;
                    return;
                }
            }
        }
        [Bindable("change")]
    	[Bindable("collectionChange")]
        [Bindable("valueCommit")]
        public function get selectedProc():String{
            return this.selectedItem.ProcID;
        }
    }
}